<?php

/**
 * Description of BackendApplication
 *
 * @author FFOZEU
 */
namespace Applications\Backend;

use Library\Application;
use Library\Router;

class BackendApplication extends Application{
    
    public function __construct(){

        parent::__construct($this);
        $this->name = 'Backend';
    }
    
     public function run(){
        if($this->user->isAuthenticated()){
            if(!$this->user->isAdmin())
                $this->httpResponse()->redirect('/');
            $router = new Router($this);
            $controller = $router->getController();
            
        }else{
            $controller = new \Applications\Modules\Users\Backend\Controller\UsersController($this, 'Users', 'Connect');
        }
        $controller->execute();
        $this->httpResponse->setPage($controller->page());
        $this->httpResponse->send();
    }
    
}

?>
